﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" 
    Inherits="CommentsTree" CodeFile="CommentsTree.aspx.cs" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">	
    <script src="<%= ResolveUrl("~/Content/ContextScripts.js") %>" language="javascript" type="text/javascript" ></script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <div style="display:none" id="ThemeIdCtrl" ><%: (ViewData["Theme"] as Blog.Core.Theme).ID %></div>

    <h2><%: (ViewData["Theme"] as Blog.Core.Theme).ThemeHeader%></h2>
    <br />
    <%= (ViewData["Theme"] as Blog.Core.Theme).Description %>
    <br />
	
    <div class="quotes leftquotes"></div>
    <h3>Комментарии</h3>
    <br />
    
    <% foreach (Blog.Core.MessageTreeItem message in ViewData["Messages"] as IEnumerable<Blog.Core.MessageTreeItem>) { %>

    <%= string.Format("<table class=\"treemess-table\" name=\"TreeMessItem\" id=\"Level_{0}_{1}\">", message.ID, message.TreeID) %>
    <tr>
        <%= string.Format("<td style=\"width: {0}px\">", message.Level * 30) %>
        <td>
        
        <table class="treemess-message-table">
            <tr>
                <th rowspan="2">
                    <span><%: message.User%></span>
                    <div><%: message.Date == null ? string.Empty : message.Date.Value.ToString("f")%></div>
                </th>
                <td>
                    <p><%: message.Text%></p>
                </td>
            </tr>
            <tr>
                <%= GetAnswerCellBlock(message)%>
            </tr>
        </table>   
        
        </td>
    </tr>     
    </table> 
           
    <%} %>
    
    <div id="AnswerBlock">
        <h4>Новый коментарий:</h4>        
        <fieldset>
            <textarea rows="1" cols="1" id="MessageText" name="MessageText"></textarea>
            <p><a class="more" id="CreateCommentButton" href="">Сохранить</a></p>
        </fieldset>
    </div>
    
    <% if (Request.IsAuthenticated) { %>
        <div id="NewAnswerBlock">
            <h4>Новый коментарий:</h4>
            <fieldset>
                <textarea rows="1" cols="1" id="NewMessageText" name="NewMessageText"></textarea>
                <p><a class="more" href="javascript:AnswerExecute(0,0)">Сохранить</a></p>
            </fieldset>
        </div>
    <% } else { %>
        <h4>Чтобы оставить комментарий, <%: Html.ActionLink("Войдите", "LogOn", "Account", null, new Dictionary<string, object>() { { "class", "more" } })%> или <%: Html.ActionLink("зарегистрируйтесь", "Register", "Account",null, new Dictionary<string, object>() { { "class", "more" }})%> (это займет всего минуту!)</h4>
    <% } %>
        
	<div class="quotes rightquotes"></div>
    <br />
    <%: Html.ActionLink("Back", "Index", "Home", null, new Dictionary<string, object>() { { "class", "more" } }) %>
    <br />
    <br />
</asp:Content>
